{% extends 'myhome/baselogin.html' %}

{%block body%}
<div class="res-banner">
    <div class="res-main">
        <div class="login-banner-bg"><span></span><img src="/static/myhome/images/big.png"/></div>
        <div class="login-box">

            <div class="mr-tabs" id="doc-my-tabs">
                <ul class="mr-tabs-nav mr-nav mr-nav-tabs mr-nav-justify">
                    <li class="mr-active">注册</li>
                </ul>
                <div class="mr-tabs-bd">
                    <div class="mr-tab-panel mr-active">

                         <div class="login-form">
                            <form action="{% url 'myhome_register' %}" method="post">
                            {% csrf_token %}
                                <!--<div class="user-email">
                                    <label for="email"><i class="mr-icon-envelope-o"></i></label>
                                    <input type="email" name="" id="email" placeholder="请输入邮箱账号">
                                </div>-->
                                <div class="user-pass">
                                    <label for="passwordRepeat"><i class="mr-icon-mobile"></i><span style="color:red;margin-left:5px">*</span></label>
                                    <input type="text" name="uphone" id="tel" placeholder="请输入手机号">
                                </div>
                                <div class="user-pass">
                                    <label for="password"><i class="mr-icon-lock"></i></label>
                                    <input type="password" name="upassword" id="password" placeholder="设置密码">
                                </div>
<!--                                <div class="user-pass">
                                    <label for="passwordRepeat"><i class="mr-icon-lock"></i></label>
                                    <input type="password" name="" id="passwordRepeat" placeholder="确认密码">
                                </div>-->


                            </div>
                        <div class="login-links">
                            <label for="reader-me">
                                <input id="reader-me" type="checkbox"> 点击表示您同意商城《服务协议》

                            </label>
                            <a href="{% url 'myhome_login' %}" class="mr-fr">登录</a>
                        </div>
                        <div class="mr-cf">
                            <input type="submit" name="" onclick="mr_verify()" value="注册" class="mr-btn mr-btn-primary mr-btn-sm mr-fl">
                        </div>
                            </form>
                    </div>


                </div>
            </div>

        </div>
    </div>
</div>
{%endblock%}

{%block script%}
<script>
    function mr_verify(){

        //获取表单对象
        var email=document.getElementById("email");
        var password=document.getElementById("password");
        var passwordRepeat=document.getElementById("passwordRepeat");
        var tel=document.getElementById("tel");

        //验证项目是否为空
        if(email.value==='' || email.value===null){
            alert("邮箱不能为空！");
            return;
        }
        if(password.value==='' || password.value===null){
            alert("密码不能为空！");
            return;
        }
        if(passwordRepeat.value==='' || passwordRepeat.value===null){
            alert("确认密码不能为空！");
            return;
        }
        if(tel.value==='' || tel.value===null){
            alert("手机号码不能为空！");
            return;
        }

        if(password.value!==passwordRepeat.value ){
            alert("密码设置前后不一致！");
            return;
        }
        //验证邮件格式
        apos = email.value.indexOf("@")
        dotpos = email.value.lastIndexOf(".")
        if (apos < 1 || dotpos - apos < 2) {
            alert("邮箱格式错误！");
        }
        else {
            alert("邮箱格式正确！");
        }

        //验证手机号格式
        if(isNaN(tel.value)){
            alert("手机号请输入数字！");
            return;
        }
        if(tel.value.length!==11){
            alert("手机号是11个数字！");
            return;
        }

        alert('注册成功！');

    }
</script>
{%endblock%}
